/**
 * 
 */
package com.simple.user;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;
import com.jfinal.log.Logger;

/**
 * 用户权限拦截器
 * @author zhanxj
 *
 */
public class UserInterceptor implements Interceptor {
	private static Logger logger = Logger.getLogger(UserInterceptor.class);
	public void intercept(ActionInvocation ai) {
		logger.info(ai.getActionKey());
		Controller controller =ai.getController();
		String username=controller.getSessionAttr("userInfo");
		if(username!=null){
			ai.invoke();
		}else{
			controller.redirect("/login/login.jsp");
		}
	}

}
